package cn.dansj.common.request.annotation.http;

import cn.dansj.common.request.annotation.encrypt.EncryptResponseData;
import cn.dansj.common.request.annotation.logging.Nologging;
import cn.dansj.common.request.annotation.permission.Permission;
import cn.dansj.common.utils.enums.BooleanType;
import cn.dansj.common.utils.enums.UserType;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.*;

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping
@Permission
@EncryptResponseData
@RestController
@Nologging
public @interface RequestMappingMethod {
    /**
     * Alias for {@link RequestMapping#name}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String name() default "";

    /**
     * Alias for {@link RequestMapping#value}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] value() default {};

    /**
     * Alias for {@link RequestMapping#path}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] path() default {};

    /**
     * Alias for {@link RequestMapping#params}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] params() default {};

    /**
     * Alias for {@link RequestMapping#headers}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] headers() default {};

    /**
     * Alias for {@link RequestMapping#consumes}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] consumes() default {};

    /**
     * Alias for {@link RequestMapping#produces}.
     */
    @AliasFor(annotation = RequestMapping.class)
    String[] produces() default {};

    @AliasFor(annotation = RequestMapping.class)
    RequestMethod[] method() default {};

    /**
     * 返回值是否加密
     */
    @AliasFor(annotation = EncryptResponseData.class, value = "value")
    BooleanType encrypt() default BooleanType.UNSET;

    /**
     * 要加密的字段
     */
    @AliasFor(annotation = EncryptResponseData.class, value = "filed")
    String encryptField() default "data";

    /**
     * 接口权限白名单
     */
    @AliasFor(annotation = Permission.class, value = "value")
    BooleanType permission() default BooleanType.UNSET;

    /**
     * 接口权限用户类型
     */
    @AliasFor(annotation = Permission.class)
    UserType userType() default UserType.INHERITED;

    /**
     * 是否记录日志，默认记录
     */
    @AliasFor(annotation = Nologging.class, value = "value")
    BooleanType nologging() default BooleanType.UNSET;
}
